include<tools/util.scad>
include<tools/threads.scad>

$fn=100;
box_length=100;
box_width=60;
box_height=30;

k_width=10;
round_r=1;


//base_part();
//translate([-box_length/2,box_width+10,k_width/2])rotate([0,90,0])
slip_part();
//translate([box_length/2-20,box_width/2+20,0])screw_cap(ch=box_height/2-5);

module base_part(){
 
 translate([0,0,box_height/2])
    union(){
        difference(){
            d_round_cube(xyz=[box_length,box_width,box_height],rr=round_r,center=true);
            translate([0,0,box_height/4- round_r])
            cube([box_length-2*k_width,box_width + 2*round_r,box_height/2 + 2*round_r],center=true);

            translate([0,10,-box_height/4])slot_mask();
            translate([0,-10,-box_height/4])slot_mask();
 
          translate([box_length/2-k_width/2,0,5]){
            rotate([0,0,90])translate([0,2.3,0])rotate([90,0,0])screw_mask(ch=box_height/2-5);
              
          }
          translate([box_length/2-k_width-1,0,5])rotate([0,90,0])cylinder(h=k_width+5,d=5.2);
            
        }
        translate([-(box_length/2-k_width+3),6,box_height/2])cylinder(d=6,h=15);
        translate([-(box_length/2-k_width+3),-6,box_height/2])cylinder(d=6,h=15);
    }
    //固定脚
    difference(){
        translate([-5,-box_width/2-20,0])cube([10,22,3]);
        translate([0,-box_width/2-10,0])cylinder(h=5,d=5);
    }
    difference(){
        
        translate([-5,box_width/2-2,0])cube([10,22,3]);
        translate([0,box_width/2+9,0])cylinder(h=5,d=5);
    }
}

module slip_part(){
    difference(){
        d_round_cube(xyz=[k_width,box_width,box_height],rr=round_r,center=true);
        translate([0,0,-box_height/4])cube([k_width+round_r,10.4,box_height/2 + 2*round_r],center=true);
        new_y=box_width/4+7.5-round_r/2-0.5;
        translate([0,new_y,-box_height/4])cube([k_width+round_r,box_width/2-14+round_r,box_height/2 + 2*round_r],center=true);
         translate([0,-new_y,-box_height/4])cube([k_width+round_r,box_width/2-14+round_r,box_height/2 + 2*round_r],center=true);
    }
    translate([k_width/2-3,6,box_height/2])cylinder(d=6,h=15);
    translate([k_width/2-3,-6,box_height/2])cylinder(d=6,h=15);
    
}

module slot_mask(){
    cube([box_length-2*k_width,10,box_height/2],center=true);
}

module screw_mask(ch=20){
    d_six_side_cube(edge=4.5,height=4.6);
    translate([-4.5,0,0])cube([9,ch,4.6]);
}
module screw_cap(ch=20){
    difference(){
        translate([-4.3,0,0])cube([8.6,ch,4.4]);
        d_six_side_cube(edge=4.3,height=4.4);
    }
}
